<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var minSteps = function(n) {
    const f = new Array(n + 1).fill(0);
    for (let i = 2; i <= n; ++i) {
        f[i] = Number.MAX_SAFE_INTEGER;
        for (let j = 1; j * j <= i; ++j) {
            if (i % j === 0) {
                f[i] = Math.min(f[i], Math.floor(f[j] + i / j));
                f[i] = Math.min(f[i], Math.floor(f[i / j] + j));
            }
        }
    }
    return f[n];
};
  </script>
</body>
</html>